#include<iostream>
#include<cstring>
using namespace std;
const int N = 1e5 + 10;
int l[N], r[N];
int n, m;
int a[N], b[N];
int s[N];

bool check(int x)
{
	for (int i = 1; i <= n; i++) {
		b[i] = 0;
		s[i] = 0;
	}
	for (int i = 1; i <= x; i++) {
		b[a[i]] = 1;
	}
	for (int i = 1; i <= n; i++) {
		if (b[i])s[i] = s[i - 1] + 1;
		else s[i] = s[i - 1];
		//	cout<<"s[i]=="<<s[i]<<endl;
	}
	for (int i = 1; i <= m; i++) {
		int len = r[i] - l[i] + 1;
		if (s[r[i]] - s[l[i] - 1] > len / 2)return 1;
	}
	return 0;
}
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> n >> m;
		memset(l, 0, sizeof(l));
		memset(r, 0, sizeof(r));
		memset(a, 0, sizeof(a));
		for (int i = 1; i <= m; i++) {
			cin >> l[i] >> r[i];
		}
		int q;
		cin >> q;
		for (int i = 1; i <= q; i++) {
			cin >> a[i];
		}
		int l = 0, r = q + 1;
		while (l + 1 < r) {
			int mid = l + r >> 1;
			//cout<<"mid=="<<mid<<endl;
			if (check(mid))r = mid;
			else l = mid;
		}
		int ans = r;
		if (r == q + 1)ans = -1;
		//cout<<"ans=="<<endl;
		cout << ans << endl;
	}
	return 0;
}